package lew.bing.exp.spr;

import lew.bing.exp.spr.filters.TestFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.EnumSet;

/**
 * Created by 刘国兵 on 2018/7/28.
 */
//@WebListener
public class TestWebListener implements ServletContextListener {
    private static final Logger logger = LoggerFactory.getLogger(TestWebListener.class);
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        logger.info("testWebListener");
//        System.out.println(sce.getServletContext());
        FilterRegistration.Dynamic dynamic = sce.getServletContext().addFilter("test-filter", new TestFilter());
//        dynamic.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class),false,"/*");
//        logger.info("testWebLister init with filter =>",dynamic);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
